<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item>
                    <el-input class="w-[280px]" v-model="queryParams.keyword" placeholder="学号/学生姓名" clearable
                        @keyup.enter="resetPage" />
                </el-form-item>

                <el-form-item label="联系方式">
                    <el-select class="w-[280px]" v-model="queryParams.channel">
                        <el-option v-for="(item, key) in ClientMap" :key="key" :label="item" :value="key" />
                    </el-select>
                </el-form-item>

                <el-form-item label="账号状态">
                    <el-select class="w-[240px]" v-model="queryParams.censor_status">
                        <el-option label="全部" value="" />
                        <el-option label="未审核" :value="0" />
                        <el-option label="合规" :value="1" />
                        <el-option label="不合规" :value="2" />
                        <el-option label="疑似" :value="3" />
                        <el-option label="审核失败" :value="4" />
                    </el-select>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none" shadow="never">
            <el-table stripe class="mt-2" size="large" v-loading="pager.loading" :data="pager.lists">
                <el-table-column label="学号" prop="sn" min-width="120" />
                <el-table-column label="姓名" min-width="100" />
                <el-table-column label="使用值" prop="nickname" min-width="120" />
                <el-table-column label="机器人数量" prop="mobile" min-width="100" />
                <el-table-column label="联系方式" prop="email" min-width="140" />

                <el-table-column label="账号状态" min-width="160">
                    <template #default="{ row }">
                        <span style="color: #1abc9c">• 启用</span>
                        <!-- <span style="color: #f59a23">• 停用</span> -->
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="package_time" min-width="180">
                    <template #default="{ row }">
                        <div>{{ row.package_time }}</div>
                        <div v-if="row.package_is_overdue" class="text-[#FBAE00]">
                            已到期
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="操作" min-width="360" fixed="right">
                    <template #default="{ row }">
                        <div class="flex items-center">
                            <el-button plain type="primary" @click="gotoDeatil">
                                详情
                            </el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" background="red" layout="prev, pager, next, sizes" />
            </div>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="consumerLists">
import { usePaging } from "@/hooks/usePaging";
import { getStudentList, } from "@/api/consumer";
import { useDictOptions } from "@/hooks/useDictOptions";
import { ClientMap } from "@/enums/appEnums";

const router = useRouter();

const popShow = ref(false);

// 获取当前的url ?后面的参数
const route = useRoute();

const queryParams = reactive({
    teacher_id: route?.query?.id,
});

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: getStudentList,
    params: queryParams,
});



//弹框关闭
const popClose = () => {
    getLists();
    popShow.value = false;
};

onActivated(() => {
    getLists();
});

console.log("route?.query?.id,");

getLists();

// 路由跳转
const gotoDeatil = () => {
    router.push("/user/teacher/detail");
};
</script>

<style lang="scss" scoped></style>
